<!-- 任务执行情况 -->
<template>
  <el-dialog title="选择负责人" :visible.sync="dialogTableVisible" @close="$emit('update:visible',false)" :modal-append-to-body="false" >
    <el-table :data="arryList"
              height="400"
              :stripe="tableoption.tableStripe"
              :border="tableoption.tableBorder"
              tooltip-effect="dark"
              ref="table"
              @row-click="rowClick">
      <el-table-column width="50">
        <template slot-scope="scope"><el-radio v-model="radio" :label="scope.row.id" class="radioCheckBox">{{scope.row.id}}</el-radio>
        </template>
      </el-table-column>
      <el-table-column label="班级"  align="center">
        <template slot-scope="scope">
          {{scope.row.classes?scope.row.classes.class_name:'未记录'}}
        </template>
      </el-table-column>
      <el-table-column label="姓名"
                       prop="realname"
                       align="center">

      </el-table-column>
    </el-table>
    <el-pagination
            background
            :page-size="page.pagesize"
            :current-page="page.pageindex"
            layout="total, prev, pager, next"
            :total="page.total"
            @current-change="handleSizeChange"></el-pagination>
    <div slot="footer" class="dialog-footer">
      <el-button @click="dialogTableVisible = false" size="small">取 消</el-button>
      <el-button type="primary" @click="userlist()" size="small">确 定</el-button>
    </div>
  </el-dialog>
</template>
<script>
  import api from '@/utils/api.js'
  import {pagination, tableoption} from '@/utils/util.js'

  export default {
    name: 'taskListDialog',
    props: ['visible'],
    watch: {
      visible () {
        this.dialogTableVisible = this.visible
        if (this.visible) {
          this.InitFn()
        }
      }
    },
    data () {
      return {
        radio: '',
        applyBox: null,
        tableoption: tableoption,
        page: {
          pageindex: pagination.pageIndex,
          pagesize: pagination.pageSize,
          total: pagination.total
        },
        dialogTableVisible: this.visible,
        arryList: []
      }
    },
    created () {
    },
    methods: {
      InitFn () {
        this.$fetch(api.admin_user_index, {p: this.page.pageindex}).then((response) => {
          if (response.code === 0) {
            this.arryList = response.list.data
            this.page.total = response.list.total
          } else {
          }
        }).catch((err) => {
          console.log(err)
        })
      },
      // 分页
      handleSizeChange (val) {
        this.page.pageindex = val
        this.InitFn()
      },
      // 用户人员分页
      handleUserChange (val) {
        this.userPage = val
        this.InitFn()
      },
      // 行选中
      rowClick (option) {
        this.applyBookBox = option.name
        this.radio = option.id
        this.applyBox = option
      },
      userlist () {
        console.log('选择的数据：', this.applyBox)
        this.$emit('cornerUserFile', this.applyBox)
        this.dialogTableVisible = false
      }
    }
  }
</script>
